<div class="box white_bg">
<?if (!isset($this->viewParams['items'])) :?>
 No <?=$this->viewParams['contentType'] ?> posted yet
<?else:?>
<?
$pageCount = ceil($this->viewParams['paginator']->getTotalItemCount()/$this->viewParams['paginator']->getItemCountPerPage());
?>

<?
	$sess = new Zend_Session_Namespace(CLU_NS);
?>

<?foreach ($this->viewParams['items'] as $i=> $item) :?>
<?if($this->viewParams['items'][0]['id'] != $item['id']) :?>
 	<div class="box" style="border-bottom:1px solid #DFDFDF;">
 	<div class="mouse_action-<?=$item['id']?>">
    	<div class="chitiet_title">&nbsp;&nbsp;
		<?	     
	        if (isset($this->viewParams['aList'][$item['id']]['article_title']))
	        { 
	     		$title = $this->viewParams['aList'][$item['id']]['article_title'];
	     		$body = $this->viewParams['aList'][$item['id']]['article_body'];	
			}
        	else
        	{
        		$title = $item['title'];
        		$body = $item['body'];
        	}
        	$metadata = unserialize($item['metadata']);
	        ?>
     		
     		<a href="<?= $link = $this->hvnUrl(array('module' => 'blog', 'action' => "view"),"node") . "?id=" . $item['id'];?>">
	     		<?= ($this->viewParams['paginator']->getCurrentPageNumber() - 1) * $this->viewParams['paginator']->getItemCountPerPage() + $i + 1?>. <?=$title ?>
	     	</a>
 		</div>
<div class="blog_news" align="left">
<div class="blog_news_left">
	<?=t(136)?>
	<a href="<?=$this->hvnUrl(array('action'=>'view'),'account')?>?id=<?=$item['poster_id']?>"> <span><?=$metadata['poster_name']?></span> </a>
	<?=t(1020)?>  
	<? if (isset($item['created'])) :?>
	<?=date("j/n/Y", $item['created'])?>
	<?else :?>
	<?=date("j/n/Y", $this->viewParams["aList"][$item['id']]['article_post_time'])?>
	<?endif ?>,
</div>
<div class="blog_news_right"><?=$item['views'] + 100 ?> <?=t(1019)?>  - <?=$item['comments']?> <?=t(601)?><?if($sess->viewLang == 'en' && $item['comments'] > 0) echo 's'?>
 </div>
<div class="clear"></div></div>
<div class="clear"></div>
<div class="news_img">
<? if (isset($item['thumb'])) :?>
<img src="<?=str_replace("/original/", "/medium/", $item['thumb'])?>" align="absmiddle" />
<?else :?>
<img src="/public/themes/prime/images/common/75x75_no_image.gif" align="absmiddle" />
<?endif?> 
</div>

 <div class="text">
     <?= substring_n_words(strip_tags($body), 100) ;?> ...
 </div>
 
 <div class="detail">
 	<a  style="color:#324171;" href="<?=$link?>"><?=t(150)?>...</a>
 </div>

 <div style="height:30px;width:400px; padding: 2px 0 0;">
        <div align = "right" class = "tr-action" style="display:none">
        <?if (($sess->userId == $item['poster_id'] && strpos ($sess->userPermissions, 'update own blog')
                        )):
             ?>
        <a href="<?=$edit = $this->hvnUrl(array('module' => 'blog', 'action' => "edit"),"node") . "?id=" . $item['id'];;?>"><?=t(38)?> </a>|
        <?endif?>
        <?if ((isset($sess->userId) && (strpos($sess->userPermissions, 'administer everything') ||
                   ($sess->userId == $item['poster_id'] && strpos ($sess->userPermissions, 'delete own blog')
                        )))):
             ?>
    	<a href="javascript:void()" name="item-delete-blog-<?=$item['id']?>"><?=t(31)?></a>
     <?endif?>
        </div>
    </div>
  </div>
  </div>
	<?endif?>
<?endforeach ?>
<div>

<? if ($pageCount > 1) :?>
	<?= $this->paginationControl($this->viewParams['paginator'], 'Sliding', '/modules/common/views/scripts/commonTheme/commonLang/common/clu-pagination-control.phtml',
							    array('searchUrl' => $this->viewParams['searchUrl'])); ?>
<?endif ?>
</div>
<?endif ?>

</div>
<style type="text/css">
.gray-bg
{
	background-color : #c8cbd6;
}
</style>
<script type="text/javascript">

$(function() {
    $("[class^=mouse_action]").mouseover(function(e){
                        $(this).find(".tr-action").show();
                        $(this).find(".blog_news").addClass("gray-bg");
                }).mouseout(function(){
                        $(this).find(".tr-action").hide();
                        $(this).find(".blog_news").removeClass("gray-bg");
                });
    
	$("[name^=item-delete-]").click(function(e){
		var del=confirm("Do you want to delete this item?");
		deleteId = this.name.split('-')[3];
		type = this.name.split('-')[2];
		messeage = '';
//		alert(deleteId);
		if (del){	
			if(type == 'place')
			{
				$.getJSON("/<?=$sess->viewLang?>/place/ajax/delete-place", {'id': deleteId},function(json) {
					if(json.success)	
						$(".mouse_action-"  + deleteId).css('background-color','red').fadeOut(2000);
	               	else
	               		$(".mouse_action-"  + deleteId).show().html("<?=t(729)?>");
	               return false;
				});
			}
			else if(type == 'event')
			{
				$.getJSON("/<?=$sess->viewLang?>/event/ajax/delete-event", {'id': deleteId},function(json) {
					if(json.success)	
						$(".mouse_action-"  + deleteId).css('background-color','red').fadeOut(2000);
	               	else
	               		$(".mouse_action-"  + deleteId).show().html("<?=t(729)?>");
	               return false;
				});
			}
			else
			{
				$.getJSON("/<?=$sess->viewLang?>/node/ajax/delete-node", {'id': deleteId,'type':type},function(json) {
					if(json.success)	
						$(".mouse_action-"  + deleteId).css('background-color','red').fadeOut(2000);
	               	else
	               		$(".mouse_action-"  + deleteId).show().html("<?=t(729)?>");
	               return false;
				});
			}
		}else
			return false;
	});
});
</script>
